Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WEB-2443] fix: workspace settings access validation updated #5606

Merged
merged 1 commit into from
Sep 16, 2024

Conversation

anmolsinghbhatia
Copy link
Collaborator

@anmolsinghbhatia anmolsinghbhatia commented Sep 13, 2024

Changes:

This PR resolves the access validation issue in workspace settings.

Reference:

[WEB-2443]

Summary by CodeRabbit

  • New Features

    • Introduced enhanced authorization checks for accessing workspace settings.
    • Updated sidebar dropdown to display links based on user permissions.
  • Bug Fixes

    • Restricted access to "General" and "Members" settings to only admin users.
  • Improvements

    • Improved user experience by providing appropriate feedback for unauthorized access.

Copy link
Contributor

coderabbitai bot commented Sep 13, 2024

Walkthrough

The changes introduce enhanced user permission checks across various components related to workspace settings. The WorkspaceSettingLayout component now restricts access based on user roles, allowing only admins to view the settings. Similar modifications are made to the WORKSPACE_SETTINGS constants, limiting access to specific settings. The sidebar dropdown component also incorporates permission checks to control link visibility based on user roles, ensuring that only authorized users can see certain options.

Changes

File Path Change Summary
web/app/[workspaceSlug]/(projects)/settings/layout.tsx Introduced authorization check using useUserPermissions to restrict access to settings for non-admin users, displaying NotAuthorizedView when unauthorized.
web/ce/constants/workspace.ts Modified access permissions for WORKSPACE_SETTINGS.general and WORKSPACE_SETTINGS.members to allow only EUserPermissions.ADMIN.
web/core/components/workspace/sidebar/dropdown.tsx Enhanced user permission handling by adding access properties to links, ensuring only links for which the user has permissions are rendered.

Possibly related PRs

Suggested labels

🐛bug

🐰 In a workspace where permissions play,
Only the admins get to stay.
With checks in place, the rules are clear,
Non-admins now must disappear.
A safer space for all to roam,
In this layout, they find their home! 🌟

Tip

OpenAI O1 model for chat
  • We have deployed OpenAI's latest O1 model for chat.
  • OpenAI claims that this model has superior reasoning capabilities than their GPT-4o model.
  • Please share any feedback with us in the discussions post.

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f155a13 and 02911f9.

Files selected for processing (3)
  • web/app/[workspaceSlug]/(projects)/settings/layout.tsx (1 hunks)
  • web/ce/constants/workspace.ts (1 hunks)
  • web/core/components/workspace/sidebar/dropdown.tsx (5 hunks)
Additional comments not posted (11)
web/app/[workspaceSlug]/(projects)/settings/layout.tsx (5)

3-4: LGTM!

The imports are necessary for the component definition and do not introduce any issues.


11-13: LGTM!

The imports are necessary for implementing the authorization check and do not introduce any issues.


19-25: LGTM!

The component definition and usage of the useUserPermissions hook are correct. The derived value isWorkspaceAdmin is correctly computed using the allowPermissions function.


32-45: LGTM!

The conditional rendering logic is correct and effectively restricts access to the settings for non-admin users. The NotAuthorizedView component is used appropriately to provide feedback when access is denied. The settings layout structure remains largely the same.


49-51: LGTM!

The export statement is correct and does not introduce any issues.

web/ce/constants/workspace.ts (2)

12-12: LGTM!

Restricting access to the "General" settings to only admin users aligns with the PR objective and improves the security of the workspace settings.


20-20: LGTM!

Restricting access to the "Members" settings to only admin users aligns with the PR objective and improves the security of the workspace settings.

web/core/components/workspace/sidebar/dropdown.tsx (4)

18-19: LGTM!

The imports are necessary for implementing user permission checks in the component and are correctly used.


29-36: LGTM!

The access property is correctly defined using the EUserPermissions enum and is used to control the visibility of the links based on the user's permissions.


52-52: LGTM!

The allowPermissions function is correctly used to check if the user has the necessary permissions to view the links.


Line range hint 175-234: LGTM!

The code segment correctly renders the links based on the user's permissions. The allowPermissions function is correctly used to check if the user has the necessary permissions to view the links, and the EUserPermissionsLevel.WORKSPACE enum is correctly used to specify the permission level.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants